/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Server;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.cs.zookeeper.CuratorManager;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.ArrayList;
/*    */ import java.util.Iterator;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import java.util.Set;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public final class GetAllActiveServers
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 40 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 41 */     checkRight(zsc, context, null, AdminRight.PR_SYSTEM_ADMIN_ONLY);
/* 42 */     Element response = zsc.createElement(AdminConstants.GET_ALL_ACTIVE_SERVERS_RESPONSE);
/* 43 */     CuratorManager curator = CuratorManager.getInstance();
/* 44 */     if (curator == null) {
/* 45 */       return response;
/*    */     }
/*    */     Set<String> serverIds;
/*    */     try {
/* 49 */       serverIds = curator.getActiveServers();
/*    */     } catch (Exception e) {
/* 51 */       throw ServiceException.FAILURE("error while getting active servers", e);
/*    */     }
/* 53 */     Provisioning prov = Provisioning.getInstance();
/* 54 */     List<Server> servers = new ArrayList();
/* 55 */     for (String serverId : serverIds) {
/* 56 */       Server server = prov.getServerById(serverId);
/* 57 */       servers.add(server);
/*    */     }
/*    */     
/* 60 */     AdminAccessControl aac = AdminAccessControl.getAdminAccessControl(zsc);
/*    */     
/* 62 */     for (Iterator<Server> it = servers.iterator(); it.hasNext();) {
/* 63 */       Server server = (Server)it.next();
/* 64 */       if (aac.hasRightsToList(server, Rights.Admin.R_listServer, null)) {
/* 65 */         GetServer.encodeServer(response, server, true, null, aac.getAttrRightChecker(server));
/*    */       }
/*    */     }
/* 68 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 73 */     notes.add("Only system admins are allowed.");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/GetAllActiveServers.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */